/*-----------------------------------------------------------------------------
 * event_malloc.h - definitions for the event malloc library
 *
 * Forhad Ahmed, July 2009
 *-----------------------------------------------------------------------------
 */

#ifndef _EVENT_MALLOC_H_
#define _EVENT_MALLOC_H_

#include "event_private.h"


/*
 * Free'd event object signature
 */
#define EVENT_CHUNK_FREE 0xCCCCCCCC

/*
 * Macro to get the chunk index given an event object
 */
#define EVENT_CHUNK_INDEX(ev) ((ev->chunk->data - ev) / sizeof(ev))


/*
 * 
 */
typedef struct event_chunk_t {
    int   size;
    int   inuse; 
    int   last_free;
    event data[0];
} event_chunk;


/*
 * 
 */
event * 
event_malloc(event_chunk *chunk);


/*
 * 
 */
void   
event_free(event *ev);


#endif /* _EVENT_MALLOC_H_ */

